﻿using System;
using System.Web.UI;
using System.Net.Mail;

namespace Nurturehood
{
    public partial class ContactUs : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            using (MailMessage message = new MailMessage())
            {
                message.From = new MailAddress(txtEmail.Text);
                message.To.Add(new MailAddress("contact@nurturehood.com"));
                message.Subject = txtName.Text + " have Query\\Feedback related to Nurturehood.";
                
                message.Body = "Hi Nurturehood,\n\n" + txtName.Text
                    + " have Query\\Feedback related to Nurturehood. The Mobile number is "
                    + txtMobile.Text + ". Please find the Query\\Feedback below:\n"+ txtQuery.Text +"\n\n Thanks\n Nurturehood";
                SmtpClient client = new SmtpClient();
                //This is GoDaddy email hosting server
                client.Host = "relay-hosting.secureserver.net";
                client.Send(message);
                ResetForm();
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "emailsent", "alert('Your Query/Feedback is submited. Thanks for your valuable time.')", true);
            }
        }

        private void ResetForm()
        {
            txtEmail.Text = string.Empty;
            txtMobile.Text = string.Empty;
            txtName.Text = string.Empty;
            txtQuery.Text = string.Empty;
        }
    }
}